<?php
/**
 * 登陆日志
 * @author yuxing
 *
 */
class SignLog extends CActiveRecord
{
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }
    
    public function tableName()
    {
        return '{{sign_log}}';
    }
    
    /**
     * 增加一条日志
     */
    public function insertLog()
    {
        $this->setIsNewRecord(true);
        $this->uid = Yii::app()->user->id;
        $request = Yii::app()->request;
        $this->ip = ip2long($request->userHostAddress);
        $this->referer = $request->getUrlReferrer();
        $this->agent = $request->userAgent;
        $this->host = $request->userHost;
        $this->sign_datetime = date('Y-m-d H:i:s');
        return $this->save();
    }
}